package cn.yunhe.servlet.FboardSboard;

import cn.yunhe.service.FboardService;
import cn.yunhe.service.SboardService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/productFirstClass2AddServlet")
public class productFirstClass2AddServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //s1:参数接收
        String firstClassName=request.getParameter("firstClassName");
        System.out.println("<===firstClassName====>"+firstClassName);
        //s2:
        FboardService fboardService=new FboardService();
        //s3:
        Boolean flag=fboardService.addFboard(firstClassName);

        if (flag){
            System.out.println("<===新增成功==>");
            response.sendRedirect("secondBoardListServlet");
        }else {
            System.out.println("<====新增失败====>");
            response.sendRedirect("manage/productFirstClass-addFirstClass.jsp");
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
